<?php
// sae 懒人函数包
include( 'lazy.lite.php' ); 
session_start();
// 远程抓取页面
echo lz_fetch_url('http://g.cn');
// wuwuwuw   

// 写入文件
echo lz_put_contents( 'readme.txt' , time() );

// 读取文件
echo lz_get_contents( 'readme.txt' );

// 获取文件url
echo lz_get_url( 'readme.txt' );

// 数据库
run_sql( "CREATE TABLE IF NOT EXISTS `photo` (
  `id` int(11) NOT NULL auto_increment,
  `time` datetime NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1" );

if( db_errno() != 0 ) echo db_error();

// s() = mysql_real_escape_string
//run_sql( "INSERT INTO `photo` ( `time` ) VALUES ( '" . s( date("Y-m-d H:i:s") ) . "' )" );
run_sql( "INSERT INTO `photo` ( `time` ) VALUES ( '" .  date("Y-m-d H:i:s"). "' )" );
if( db_errno() != 0 ) echo db_error();


// 多行记录
print_r( get_data("select * from `photo` ORDER BY `id` DESC LIMIT 5") );
if( db_errno() != 0 ) echo db_error();

// 单行记录
print_r( get_line("select * from `photo` ORDER BY `id` DESC LIMIT 1") );
if( db_errno() != 0 ) echo db_error();

// 数值
echo( get_var("select count(*) from `photo` ") );
if( db_errno() != 0 ) echo db_error();

// 运行sql
$sql = "show table lala";
run_sql( $sql );

if( db_errno() != 0 ) echo db_error();


lz_mc_set("keys" , '255');

echo lz_mc_get( "keys" );


$img = lz_fetch_url( 'http://sae.sina.com.cn/static/image/logo.png' );

echo "<a href='" . lz_resize( $img , 'logo_resize.jpg' ) . "' _target='new'>resize</a> ";

echo "<a href='" . lz_fliph( $img , 'logo_h.jpg' ) . "' _target='new'>flip h</a> ";

echo "<a href='" . lz_flipv( $img , 'logo_v.jpg' ) . "' _target='new'>flip v</a> ";





?>